using System.Collections.Generic;
using Bag;
using MoonFramework.Template;
using Sirenix.OdinInspector;
using Tool;
using UnityEngine;

namespace Config
{
    [CreateAssetMenu(fileName = "建造合成配置", menuName = "Config/建造合成配置")]
    public class BuildConfig : BaseConfig
    {
        [LabelText("预制体名字")] public string BuildName;
        [LabelText("前置科技")] public List<int> PreTechs = new();
        [LabelText("合成类型")] public BuildType BuildType;
        [LabelText("合成条件")] public List<BuildConfigCondition> BuildConfigConditions = new();
        [LabelText("合成产物")] public int TargetID;

        public bool CheckWeapon() => BuildType == BuildType.Weapon;
        
        public bool CheckBuildConfigConditions()
        {
            foreach (var condition in BuildConfigConditions)
            {
                int curCount = BagManager.Instance.GetItemCount(condition.ItemID);
                if(curCount < condition.Count) return false;
            }
            return true;
        }
    }
    
    public struct BuildConfigCondition
    {
        [LabelText("物品ID"), HorizontalGroup] public int ItemID;
        [LabelText("物品数量"), HorizontalGroup] public int Count;
    }
}